﻿
using AutoMapper;
using B.S.Warehouse.Domain;
using B.S.Warehouse.ErrorCord;
using B.S.Warehouse.Read.Api.Application.Command.StockInApplicationcommands;
using MediatR;
using SqlSugar;



namespace B.S.Warehouse.Read.Api.Application.Handelr.StockInApplicationHandler
{
    public class FTStockInApplicatiHandler : IRequestHandler<FTStockInApplicatiCommand, ApiResult<List<StockInApplication>>>
    {
        private readonly ISqlSugarClient db;
        private readonly IMapper mapper;
        public FTStockInApplicatiHandler(ISqlSugarClient db, IMapper mapper)
        {
            this.db = db;
            this.mapper = mapper;
        }

        public async Task<ApiResult<List<StockInApplication>>> Handle(FTStockInApplicatiCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<StockInApplication>> result = new ApiResult<List<StockInApplication>>();
            result.Code = ApiEnum.显示成功;
            result.MAG = ApiEnum.显示成功.ToString();

            var list = await db.Queryable<StockInApplication>().Where(x => x.IsDel == false && x.Id == request.Id).ToListAsync();
            result.data = list;
            return await Task.FromResult(result);
        }
    }
}
